﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;
namespace runingman
{
    public class Sprite:Form
    {
        private int x = 50;
        private int y = 50;
        //public Graphics g;
        private Bitmap sprite;
        private Bitmap buffer;
        private Timer timer;
        private int index;
        private int colum;
        private int row;
        public Sprite()
        {
            //g = this.CreateGraphics();
            sprite= new Bitmap("sprite.png");
            buffer=new Bitmap(this.ClientSize.Width,this.ClientSize.Height);
            index=0;
        }

        private void render()
        {
            Graphics gr = Graphics.FromImage(buffer);
            gr.Clear(Color.White);
            colum = index % 5;
            //row = index / 4;
            row = 1;
            gr.DrawImage(sprite, 0,0,new Rectangle(colum * x, row * y, x, y), GraphicsUnit.Pixel);
            gr.Dispose();
            if (index > 5)
            {
                index = 0;
            }
            else index++;

        }

    }
}
